FROM openjdk:17

ENV USER=app
ENV MODULE=book-core
ENV PORT=8182

#ENV JAVA_TOOL_OPTIONS="-Xmx1024m -Xms1024m -Xss1024k"

RUN mkdir -p /home/${USER}/logs \
    mkdir -p /home/${USER}/nacos/naming/vto/ \
    && groupadd ${USER} \
    && useradd -d /home/${USER} -g ${USER} ${USER} \
    && echo "nohup java -Duser.home=/home/${USER} -jar ${MODULE}-application-1.0.jar"> /home/${USER}/start.sh

COPY ./target/${MODULE}-application-1.0.jar /home/${USER}

RUN chown -R ${USER} /home/${USER} && chmod -R a+rwx /home/${USER}

USER ${USER}

EXPOSE ${PORT}
VOLUME ["/home/${USER}/logs","/etc"]

WORKDIR /home/${USER}
ENTRYPOINT ["sh", "./start.sh", "&"]
